<template>
    <div>
        <div class="login-div">
            <Card>
                <p slot="title">登录</p>
                <i-input v-model="username">
                    <span slot="prepend">账&nbsp;&nbsp;&nbsp;号</span>
                </i-input>
                <i-input v-model="password" class="password"  type="password">
                    <span slot="prepend">密&nbsp;&nbsp;&nbsp;码</span>
                </i-input>
                <i-button type="success" class="login-btn" long @click="login">登录</i-button>
            </Card>
        </div>

    </div>
</template>

<script>
    import valid from '../lib/lvalid'
    import view from '../lib/view'
    export default {
      name: "login",
        data(){
            return {
                username: '',
                password: ''
            }
        },
        methods: {
          login(){
            if(valid.isNull(this.username)){
                view.showMsg("请输入账号！")
                return
            }

            if(valid.isNull(this.password)){
                view.showMsg("请输入密码！")
                return
            }
            localStorage.setItem('token', this.username + this.password);
            this.$router.push({path: '/'});
          }
        }
    }
</script>

<style scoped>
    .login-div{
        width: 400px;
        position: absolute;
        left: 50%;
        top: 50%;
        margin-left: -200px;
        margin-top: -200px;
    }
    .password, .login-btn{
        margin-top: 20px;
    }

</style>